/*******************************************************************************
 * Copyright (c) 2012, 2013 XML-Print Project.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     XML-Print Project - initial API and implementation
 ******************************************************************************/
package info.xmlprint.core.referencesystem;

import java.io.Serializable;
import java.util.HashMap;

import org.dom4j.Element;

public class ReferencingSystem extends AbstractBaseItem implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5632523669777354122L;

	@Override
	public void init() {
		valueMap = new HashMap<String, String>();

		nodeNameMap = new HashMap<String, String>();
		nodeNameMap.put("id", "id");//$NON-NLS-1$
		nodeNameMap.put("name", "name");//$NON-NLS-1$
		nodeNameMap.put("schema", "schema");//$NON-NLS-1$
		nodeNameMap.put("exceptions", "exceptions");//$NON-NLS-1$

		// set all value="";
		for (String k : nodeNameMap.keySet()) {
			valueMap.put(k, "");//$NON-NLS-1$
		}
	}

	@Override
	public void setRootElementName() {
		rootElementName = "referencingSystem"; //$NON-NLS-1$
	}

	@Override
	public void updateByElement(Element elem) {
		if (elem == null || !elem.getName().equalsIgnoreCase(rootElementName))
			return;
		readNodeValue(elem,
				new String[] { "id", "name", "schema", "exceptions" });//$NON-NLS-1$
	}

	// @Override
	// public Document getXmlDocument() {
	// Document doc = DocumentHelper.createDocument();
	// Element root = doc.addElement(rootElementName);
	// nodeAddChildren(root, new String[] { "id", "name", "schema", "exceptions"
	// });
	// return doc;
	// }

}
